#pragma once

#include <stdlib.h>

typedef struct ListNode
{
	int data;
	struct ListNode* next;
} *LinkedList;

inline LinkedList create_linked_list_node(int data)
{
	LinkedList node = (LinkedList)malloc(sizeof(struct ListNode));
	node->data = data;
	node->next = NULL;
	return node;
}

inline void linked_list_add_front(LinkedList dummy, int data)
{
	LinkedList node = create_linked_list_node(data);
	node->next = dummy->next;
	dummy->next = node;
}

inline void linked_list_clear(LinkedList dummy)
{
	LinkedList p = dummy->next;

	while (p != NULL)
	{
		LinkedList to_free = p;
		p = p->next;
		free(to_free);
	}
}